import 'package:flutter/material.dart';

import 'package:hzy_normal_tool/hzy_normal_tool.dart';

import '../../common/index.dart';

import '../models/index.dart';
import 'item_less_widget.dart';

class EgListWidget extends BaseLessWidget {
  const EgListWidget({
    super.key,
    required this.itemList,
    this.type = 0,
  });

  // --------- 公开属性  --------- //
  final List<TuChongItem> itemList;
  final int type;
  // --------- 私有属性  --------- //

  // --------- 生命周期  --------- //

  // --------- 构建UI  --------- //
  @override
  Widget createBody({
    required BuildContext context,
    BoxConstraints? constraints,
  }) {
    Widget body = createListView(context);
    return body;
  }

  Widget createListView(BuildContext context) {
    Widget body = ListView.separated(
      itemBuilder: (context, index) => createItemBuilder(context, index),
      separatorBuilder: (context, index) =>
          createSeparatorBuilder(context, index),
      itemCount: itemList.length,
    );
    // 移除padding
    body = configRemovePadding(
      context: context,
      child: body,
    );

    return body;
  }

  //  item构建
  createItemBuilder(BuildContext context, int index) {
    Widget body = ItemLessWidget(
      item: itemList[index],
      type: type,
    );
    return body;
  }

  //  分割线构建
  createSeparatorBuilder(BuildContext context, int index) {
    Widget body = Container();
    return body;
  }
  // --------- 触发事件  --------- //
}
